﻿/*-----------------------------------------------------------
 * 
 * 
 * 
 * 
 ------------------------------------------------------------*/

using System;
using FL.DBModule;
using FL.SysEntity;
using FL.Common;

namespace FL.Bussiness.Sys
{
    /// <summary>
    /// 记录业务数据增删改查
    /// </summary>
    public class BWriteDataLog : BaseBussnies
    {
        public BWriteDataLog()
        {
            this.entity = new t_sys_data_log();
        }


        public bool SaveLog(Guid? userID,BaseEntity _entity,string dataAction,Guid? function_id)
        {
            t_sys_data_log dataLog = this.entity as t_sys_data_log;
            dataLog.action   = dataAction;
            dataLog.id = Guid.NewGuid();
            dataLog.function_id = function_id;
            dataLog.add_user = userID==null?Guid.Empty:(Guid)userID;
            dataLog.json_data = _entity.ToJSON();
            dataLog.entity = _entity.GetTableName();
            dataLog.add_time = System.DateTime.Now;
            return Insert(dataLog);
        }
        public static BWriteDataLog Instance = new BWriteDataLog();
    }


    /// <summary>
    /// 记录业务逻辑日志
    /// </summary>
    public class BWriteActionLog : BaseBussnies
    {
        public BWriteActionLog()
        {
            this.entity = new t_sys_data_log();
        }


        public bool SaveLog(Guid? userID, BaseEntity _entity, string dataAction,string roleMessage)
        {
            t_sys_role_log dataLog = this.entity as t_sys_role_log;
            dataLog.action = dataAction;
            dataLog.id = Guid.NewGuid();
            dataLog.add_user = userID == null ? Guid.Empty : (Guid)userID;
            dataLog.role_message = roleMessage;
            dataLog.entity = _entity.GetTableName();
            dataLog.add_time = System.DateTime.Now;
            return Insert(dataLog);
        }

        public static BWriteDataLog Instance = new BWriteDataLog();
    }
}
